import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:qgchat/common/global/global.dart';
import 'BloC/releaseDynamicBloC.dart';
import 'component/uploadImg.dart';

class ReleaseDynamicView extends StatelessWidget {
  const ReleaseDynamicView({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
        preferredSize: Size.fromHeight(px(88)),
        child: AppBar(
          centerTitle: true,
          title: Text(
            "发布图片动态",
            style: TextStyle(
              fontSize: px(34),
              fontWeight: FontWeight.bold,
            ),
          ),
          actions: <Widget>[
            Container(
              width: px(125),
              child: FlatButton(
                onPressed: () {
                  BlocProvider.of<ReleaseDynamicBloc>(context).add(ReleaseDynamicEvent.release);
                },
                padding: EdgeInsets.zero,
                child: Text(
                  "确认",
                  style: TextStyle(
                    color: col("5640c6"),
                    fontSize: px(34),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
      body: Builder(
        builder: (BuildContext context) {
          return Container(
            color: col("f5f7fa"),
            child: Column(
              children: <Widget>[
                // 输入框
                Container(
                  color: Colors.white,
                  child: CupertinoTextField(
                    controller: BlocProvider.of<ReleaseDynamicBloc>(context).c,
                    maxLength: 256,
                    focusNode: BlocProvider.of<ReleaseDynamicBloc>(context).focus,
                    placeholder: '记录此刻的心情吧',
                    placeholderStyle: TextStyle(
                      color: col("bfc2cc"),
                      fontSize: px(34),
                    ),
                    maxLines: 8,
                    padding: EdgeInsets.symmetric(
                      horizontal: px(30),
                      vertical: px(20),
                    ),
                    decoration: BoxDecoration(
                      border: null,
                    ),
                  ),
                ),
                // 分割线
                Container(
                  padding: EdgeInsets.symmetric(horizontal: px(30)),
                  color: Colors.white,
                  child: Container(
                    height: 1,
                    color: col("edeff2"),
                  ),
                ),
                // 上传图片组件
                UploadImgView(),
              ],
            ),
          );
        },
      ),
    );
  }
}
